package test1;

import java.util.Scanner;

public class Solution3 {// 欧几里得算法 - 减可变规模
    public static void main(String[] args) {
        System.out.println("请输入需要求最大公约数的两个正整数：");
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        int gcd = gcd(a, b);
        System.out.println("最大公约数为：" + gcd);

    }

    private static int gcd(int num1, int num2){
        int t;
        if (num1 < num2){
            t = num1;
            num1 = num2;
            num2 = t;
        }
        while (num1 % num2 != 0){
            t = num1 % num2;
            num1 = num2;
            num2 = t;
        }
        return num2;
    }
}
